<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css"></style>
</head>
<body>
    <h1>JS 函数</h1>
    <hr>

    <script>
        // 可变参数个数的函数
        
        function sum(){
            console.log(arguments);
            var num = 0;
            for (var i = 0; i < arguments.length; i++) {
                num += arguments[i];
            }
            return num;
        }

        console.log(sum());
        console.log(sum(1));
        console.log(sum(1,46));
        console.log(sum(1,46,4686));
        console.log(sum(1,46,4686,4684,64646,99));
        

    </script>
</body>
</html>